package fr.inserm.umr915.vcfserver.bio.berkeley;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

public class DatabaseId
	{
	private long id;
	private short database;
	public DatabaseId(long id, short database) {
		super();
		this.id = id;
		this.database = database;
	}
	public long getId() {
		return id;
	}
	public short getDatabase() {
		return database;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + database;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		DatabaseId other = (DatabaseId) obj;
		if (database != other.database)
			return false;
		if (id != other.id)
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "DatabaseId [database=" + database + ", id=" + id + "]";
	}
	
	public static class Binding extends TupleBinding<DatabaseId>
		{
		@Override
		public DatabaseId entryToObject(TupleInput in) {
			long l= in.readLong();
			short d= in.readShort();
			return new DatabaseId(l,d);
			}
		@Override
		public void objectToEntry(DatabaseId o, TupleOutput out)
			{
			out.writeLong(o.id);
			out.writeShort(o.database);
			}
		
		}
	
	
	}
